var a, o = (a = require("@vant/weapp/toast/toast")) && a.__esModule ? a : {
    default: a
};

getApp();

var e = require("../../utils/config"), t = require("../../utils/request"), n = require("../../utils/api");

Page({
    data: {
        servers: [],
        showRegistBtn: !1,
        showOperatingInstructionsBtn: !1,
        headImgUrl: e.kaImgBaseUrl + "html/images/common/rich_by.png",
        kaInfo: {
            logoUrl: "",
            companyName: "",
            companyCode: "",
            companyShortName: "",
            companyTitle: "",
            registBtnName: ""
        }
    },
    onLoad: function(a) {
        if (wx.hideHomeButton(), null == a.scene) {
            var o = decodeURIComponent(a.company);
            o = "undefined" == o ? "" : o;
            var e = decodeURIComponent(a.shortname);
            e = "undefined" == e ? "" : e, (o || e) && (console.log('"ka companyCode:'.concat(o, "companyShortName：").concat(e, '"')), 
            this.setData({
                kaInfo: {
                    companyCode: o,
                    companyShortName: e,
                    logoUrl: ""
                }
            }), this.getKaConfig());
        } else wx.reLaunch({
            url: "/pages/index/index"
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getKaConfig: function() {
        var a = this;
        a.setData({
            loading: !0
        }), a.data.kaInfo.companyCode || a.data.kaInfo.companyShortName ? t.request(t.HttpMethod.GET, n.apiRoute.getKaConfigUrl, {
            companyID: a.data.kaInfo.companyCode,
            shortName: a.data.kaInfo.companyShortName
        }).then(function(t) {
            a.setData({
                loading: !1
            });
            var n = JSON.parse(t.Data);
            "0" == n.status ? (a.setData({
                kaInfo: {
                    logoUrl: "".concat(e.kaImgBaseUrl, "entlogo/").concat(n.Data.CompanyLogo),
                    companyName: "".concat(n.Data.CompanyName),
                    companyCode: a.data.kaInfo.companyCode,
                    companyShortName: a.data.kaInfo.companyShortName,
                    companyTitle: n.Data.CompanyTitle,
                    registBtnName: n.Data.RegistBtnName
                }
            }), n.Data.FamilyPackages4Mobile && a.setData({
                showRegistBtn: !0
            }), (n.Data.IsShowOperatingInstructions || n.Data.FamilyPackages4Mobile) && a.setData({
                showOperatingInstructionsBtn: !0
            }), a.getRichService()) : "R0002" == n.status ? (0, o.default)({
                message: "请扫贵单位专属小程序码进入！",
                duration: 0
            }) : "R0004" == n.status ? (0, o.default)({
                message: "贵单位的体检服务已关闭！",
                duration: 0
            }) : "R0001" == n.status ? (0, o.default)({
                message: "贵单位尚未开放该通道！",
                duration: 0
            }) : (0, o.default)({
                message: "系统异常，请稍后重试。",
                duration: 0
            });
        }) : console.log("不是扫码来的找不到单位代码，不加载大客户的配置");
    },
    getRichService: function() {
        var a = this, o = encodeURIComponent("".concat(e.familyRegUrl, "&company=").concat(a.data.kaInfo.companyCode, "&shortname=").concat(a.data.kaInfo.companyShortName)), t = encodeURIComponent("".concat(e.guidUrl, "?CompanyCode=").concat(a.data.kaInfo.companyCode, "&CompanySortName=").concat(a.data.kaInfo.companyShortName));
        e.getH5ResvLoginUrl().then(function(n) {
            var c = encodeURIComponent(n + "&company=".concat(a.data.kaInfo.companyCode, "&shortname=").concat(a.data.kaInfo.companyShortName)), i = [ {
                title: "服务",
                items: [ {
                    name: "体检预约",
                    url: "/pages/webview/webview?h5=".concat(c),
                    icon: "".concat(e.resourceRoot, "icon_resv_128.png"),
                    code: "",
                    show: !0,
                    type: "navigateTo"
                }, {
                    isBind: !0,
                    name: "报告查询",
                    url: "/pages/my-link-report-search/my-link-report-search",
                    icon: "".concat(e.resourceRoot, "icon_report_128.png"),
                    code: "",
                    show: !0,
                    type: "navigateTo"
                }, {
                    isBind: !1,
                    name: "预约记录",
                    url: "",
                    icon: "".concat(e.resourceRoot, "icon_record_128.png"),
                    code: "",
                    show: !1,
                    type: "navigateTo"
                }, {
                    isBind: !0,
                    name: "".concat(null != a.data.kaInfo.registBtnName && null != a.data.kaInfo.registBtnName && "" != a.data.kaInfo.registBtnName ? a.data.kaInfo.registBtnName : "客户登记"),
                    url: "/pages/webview/webview?h5=".concat(o),
                    icon: "".concat(e.resourceRoot, "icon_regist_128.png"),
                    code: "",
                    show: a.data.showRegistBtn,
                    type: "navigateTo"
                }, {
                    isBind: !0,
                    name: "操作指南",
                    url: "/pages/webview/webview?h5=".concat(t),
                    icon: "".concat(e.resourceRoot, "icon_guid_128.png"),
                    code: "",
                    show: a.data.showOperatingInstructionsBtn,
                    type: "navigateTo"
                } ]
            } ];
            a.setData({
                servers: i
            });
        });
    },
    urlnavigator: function(a) {
        var o = a.currentTarget.dataset.path, e = a.currentTarget.dataset.type;
        o && (e && "switchTab" == e ? wx.switchTab({
            url: o
        }) : e && "navigateTo" == e && wx.navigateTo({
            url: o
        }));
    }
});